import 'package:flutter/material.dart';
import 'package:flutter_application_1/components/root_page_head.dart';
import 'package:flutter_application_1/http/http.dart';
class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with TickerProviderStateMixin{
  TabController _tabController;

  static const List<Tab> _tabs=[
    Tab(text:'热门'),
    Tab(text: '推荐',),
    Tab(text: '好康',),
    Tab(text: '用户',),
    Tab(text: '动漫',),
    Tab(text: '语文',),
    Tab(text: '数学',),
    Tab(text: '英语',),
  ];

  final List<Widget> _tabsContent=[
    Text('111111111111'),
    Text('111111111111'),
    Text('111111111111'),
    Text('111111111111'),
    Text('111111111111'),
    Text('111111111111'),
    Text('111111111111'),
    Text('111111111111'),
  ];
  @override
  void initState() {

    super.initState();

    
   

    
    _tabController=TabController(
      length: _tabs.length,
      vsync: this,
    );

    //监听切换
    // _tabController.addListener(() {
    //   _tabController.index;
    // });
  }
  
  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
       appBar: AppBar(
         title:RootPageHead(),
         bottom: TabBar(
           tabs:_tabs,
           controller: _tabController ,
           isScrollable: true,
         ),
       ),
       body: TabBarView(
         children: _tabsContent,
         controller: _tabController,
       ),
    );
  }
}